package com.iweb.day04;

/**
 * @author WuYongheng
 * @date 2021/10/26
 * @description
 */
public class TestChange {
    public static void main(String[] args) {
        System.out.println("普通值类型的变量传值：");
        int a = 10;
        int b = 20;

        change(a, b);

        System.out.println("a:" + a);
        System.out.println("b:" + b);

        System.out.println("引用类型的变量传值：");
        MyData myData=new MyData();
        myData.numA=10;
        myData.numB=20;
        change1(myData);
        System.out.println("numA:"+ myData.numA);
        System.out.println("numB:"+ myData.numB);

    }

    public static void change1(MyData data){
        int temp=0;
        temp=data.numA;
        data.numA=data.numB;
        data.numB=temp;
    }

    public static void change(int a, int b) {
        int temp = 0;
        temp = a;
        a = b;
        b = temp;
    }
}
